/**
 * 绘制折线轨迹路径
 */
export function drawLine(viewer, positions, color, labelText) {
  const arrowSize = 10;
  for (let i = 0; i < positions.length - 2; i += 2) {
    viewer.entities.add({
      polyline: {
        positions: Cesium.Cartesian3.fromDegreesArray([
          positions[i],
          positions[i + 1],
          positions[i + 2],
          positions[i + 3],
        ]),
        width: 5,
        material: new Cesium.PolylineArrowMaterialProperty(
          Cesium.Color[color.toUpperCase()]
        ),
        arrowSize: arrowSize,
      },
      label: {
        text: labelText,
        font: "14pt sans-serif",
        fillColor: Cesium.Color.WHITE,
        style: Cesium.LabelStyle.FILL_AND_OUTLINE,
        outlineWidth: 2,
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
        pixelOffset: new Cesium.Cartesian2(0, -20),
      },
      position: Cesium.Cartesian3.fromDegrees(positions[0], positions[1]),
    });
  }
}
